package com.silverhaze.diamond.client.ui.dialogs;

import com.silverhaze.diamond.client.ui.UIHelper;

import javax.swing.*;
import javax.swing.text.MaskFormatter;
import java.awt.*;
import java.text.ParseException;

/**
 * This code is part of Kg.Axion project. Treat it as strictly confidential.
 * Created by Ivan Babanin.
 * Creation date: 01.10.11 19:47
 */
public class InputOrderIdDialog extends AbstractDialog {

    private JFormattedTextField orderIdFormattedTextField;

    public InputOrderIdDialog(Window owner) {
        super(owner, "", true, DialogButtonView.OK);

        initializeControls();
        initializeView();
    }

    private void initializeControls() {
        try {
            orderIdFormattedTextField = new JFormattedTextField(new MaskFormatter("###########"));
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }

        initializeOkCancelPanel(DialogType.VIEW);
    }

    private void initializeView() {
        getContent().add(UIHelper.hBox("Штрих код: ", orderIdFormattedTextField), BorderLayout.NORTH);
    }

    @Override
    protected void okPressed() {
        InputOrderIdDialog.this.dispose();
    }
}
